// src/api/auth/index.ts
import request from '@/utils/request';
import type { AxiosPromise } from 'axios';
import type { LoginData, LoginResult } from './types';

/**
 * 登录API 
 * 
 * @param data {LoginData}
 * @returns
 */
export function loginApi(data: LoginData): AxiosPromise<LoginResult> {
  return request({
    url: '/api/v1/auth/login',
    method: 'post',
    params: data
  });
}
// 获取验证码
export function loginVerify() {
  return request({
    url: '/api/v1/auth/captcha',
    method: 'get',
  })
}

/** 
 * 注销
 * @returns
 */
// export function logout() {
//   return request.delete(`/api/v1/auth/logout`);
// }
export function logout() {
  return request({
    url: '/api/v1/auth/logout',
    method: 'DELETE',
  })
}
// 获取当前登录用户信息
export function getUserInfo() {
  return request.get(`/api/v1/users/me`);
}
// 获取路由信息
export function getMenu() {
  return request.get(`/api/v1/menus/routes`);
}